package cn.catsdad.base.entity;

import cn.catsdad.util.SnowflakeIdUtil;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * base实体
 *
 * @author xuyl
 * @version V1.0.0 2025/4/9
 * @since V100R001
 */
@Data
@MappedSuperclass
public abstract class BaseEntity implements Serializable {

    /**
     * 初始化填充雪花id
     */
    @Id
    private Long id = SnowflakeIdUtil.getSnowflakeId();

    /**
     * 创建时间
     */
    @CreatedDate
    private LocalDateTime createdTime;

    /**
     * 创建人id
     */
    @CreatedBy
    private long creatorId;

    /**
     * 修改时间
     */
    @LastModifiedDate
    private LocalDateTime modifiedTime;

    /**
     * 修改人id
     */
    @LastModifiedBy
    private long modifierId;

    /**
     * 假删字段
     */
    private Boolean isDeleted = false;
}
